//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Collections;

namespace OpenLS.Chart.UI
{
    class PercentStackedChartLayout<T>: StackedChartLayout<T> where T: ChartStack, new()
    {
        public PercentStackedChartLayout(IEnumerable series)
            : base(series)
        {
        }

        private const double factor = 1;

        public override Bounds GetBounds(int index, int seriesIndex)
        {
            Bounds result = stacks[index].GetBounds(seriesIndex);
            double div = Math.Abs(stacks[index].Maximum) + Math.Abs(stacks[index].Minimum);
            div = div / factor;
            result.High /= div;
            result.Low /= div;
            return result;
        }
        public override double GetValue(NumericValue value, Series series, double floor)
        {
            int index = value.Index;
            int seriesIndex = series.Index;
            T t  = stacks[value.Index];
            double div = Math.Abs(stacks[index].Maximum) + Math.Abs(stacks[index].Minimum);
            div = div / factor;
            double result = t.GetValue(seriesIndex);
            result /= div;
            return result;
        }

    }
}
